package fifteenthDay;

import fourteenthDay.TreeNode;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class FindBottomLeftValue {
    public int findBottomLeftValue(TreeNode root) {
        Queue<TreeNode> queue = new ArrayDeque<>();
        queue.offer(root);
        int ans = 0;
        while (!queue.isEmpty()) {
            TreeNode t = queue.poll();
            if (t.right != null) {
                queue.offer(t.right);
            }
            if (t.left != null) {
                queue.offer(t.left);
            }
            ans = t.val;
        }
        return ans;
    }
}
